package mobi.hami.huapin.controller;

import io.swagger.annotations.*;
import mobi.hami.huapin.base.Result;
import mobi.hami.huapin.constants.BaseEnums;
import mobi.hami.huapin.dto.ProductForUserDTO;
import mobi.hami.huapin.model.base.PageVO;
import mobi.hami.huapin.service.CreateNoteAuditService;
import mobi.hami.huapin.util.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 *  个人提交纸条
 *
 * @author 阿飞 jijunjian@hami.mobi
 * @date 2018/9/13 16:40
 */
@RestController
@RequestMapping(value = "/createnoteaudit",produces = "application/json")
@Api(description = "用户提交纸条")
public class CreateNoteAuditController {

    @Autowired
    CreateNoteAuditService auditService;

    @RequestMapping(value = "/add.do", method = RequestMethod.POST)
    @ApiOperation(value = "用户提交纸条", notes = "{\n" +
            "  \"userid\": \"会员编号\",\n" +
            "  \"username\": \"用户昵称\",\n" +
            "  \"word\": \"纸条内容\",\n" +
            "  \"addressid\": \"空间id\"\n" +
            "}")
    @ApiResponses({
            @ApiResponse(code = 200,message = "{\n" +
                    "  \"success\": true,\n" +
                    "  \"code\": \"request.success\",\n" +
                    "  \"msg\": \"请求成功\",\n" +
                    "  \"data\": true  true表示成功，否则失败\n" +
                    "}")
    })
    public Result add(@RequestBody Map<String, String> reqMap) {

        return Results.successWithData(auditService.add(reqMap), BaseEnums.SUCCESS.code(), BaseEnums.SUCCESS.desc());

    }


    @RequestMapping(value = "/top5list.do", method = RequestMethod.POST)
    @ApiOperation(value = "获取用户最近提交的5个", notes = "{\n" +
            "  \"userid\": \"会员编号\",\n" +
            "  \"addressid\": \"空间id\"\n" +
            "}")
    @ApiResponses({
            @ApiResponse(code = 200,message = " {\n" +
                    "      \"id\": 6,\n" +
                    "      \"comtent\": \"纸条内容\",\n" +
                    "      \"user_id\": 会员编号,\n" +
                    "      \"create_time\": \"创建时间\",\n" +
                    "      \"audit_user_id\": null,\n" +
                    "      \"audit_time\": null,\n" +
                    "      \"audit_comment\": null,\n" +
                    "      \"status\": 审核状态: 0未审核，1，失败，2审核通过,\n" +
                    "      \"user_address_id\": 地址空间\n" +
                    "    }")
    })
    public Result newList(@RequestBody Map<String, String> reqMap) {

        return Results.successWithData(auditService.getTop5List(reqMap), BaseEnums.SUCCESS.code(), BaseEnums.SUCCESS.desc());
    }


    @RequestMapping(value = "/auth.do", method = RequestMethod.POST)
    @ApiOperation(value = "获取用户最近提交的5个", notes = "{\n" +
            "  \"id\": “自增编号”,\n" +
            "  \"remark\": \"备注\"\n" +
            "  \"status\": \"0未处理，1，审核未通过（显示未处理），2审核通过\"\n" +
            "  \"authuserid\": \"管理员编号\"\n" +
            "}")
    @ApiResponses({
            @ApiResponse(code = 200,message = "{\n" +
                    "  \"success\": true,\n" +
                    "  \"code\": \"request.success\",\n" +
                    "  \"msg\": \"请求成功\",\n" +
                    "  \"data\": 1表示正常，0表示失败\n" +
                    "}")
    })
    public Result auth(@RequestBody Map<String, String> reqMap) {

        return Results.successWithData(auditService.auth(reqMap), BaseEnums.SUCCESS.code(), BaseEnums.SUCCESS.desc());
    }


}
